// 验证token服务
define('TokenInterceptor', ['angular'], function (angular) {
    var module = angular.module('servers');
    module.factory('TokenInterceptor', function ($q, $window, AuthenticationService) {
        return {
            request: function (config) {
                config.headers = config.headers || {};
                if ($window.sessionStorage.token) {
                    // console.log($window.sessionStorage.token);
                    config.headers.Authorization = 'Bearer ' + $window.sessionStorage.token;
                }
                return config;
            },
     
            response: function (response) {
                return response || $q.when(response);
            }
        };
    });
    module.config(function ($httpProvider) {
        $httpProvider.interceptors.push('TokenInterceptor');
        // $httpProvider.defaults.headers.common = { 'My-Header' : 'value' };
    });
});